/**
 * 广告支出-单日（时间段展示）
 */   
function index(){
var startTime;
var endTime;
	$.ajax({
		url : '/Lvscore_Advertiser_Maven/byTotalDays',
        data:{"startTime":startTime,"endTime":endTime},
		type : 'post',
		dataType:'json',
		success : function(data) {
			$("#endTime").val(data.endTime);
			$("#startTime").val(data.startTime);
			var beans = data.beans;
			var advertiser = data.advertiser;
			
			/*//循环输出表格
			var dayPays = 0;
			var clickNums = 0;
			var recharges = 0;
			var balances = 0;
			var averagePrice=0;
			for(var i = 0; i < beans.length;i++){
				averagePrice+=beans[i].averagePrice;
				dayPays+=parseInt(beans[i].adPay);
				clickNums+=parseInt(beans[i].clickNum);
				recharges+=(beans[i].recharge*1).toFixed(2);
				balances+=(beans[i].balance*1).toFixed(2);
			}*/
			/*if(averagePrice=="NaN"){
				averagePrice="--";
			}*/
			
			if(beans.length=="0"){
				var body = "<tr>" +
				"<td>"+1+"</td>" +
				"<td>"+data.startTime+'至'+data.endTime+"</td>" +
				"<td class='avg'>"+'0'+"</td>" +
				"<td class='clickNums'>"+'0'+"</td>" +
				"<td class='dayPays'>"+'0'+"</td>" +
				"<td class='balances'>"+advertiser.actualBalance+"</td>" +
				"<td><a class='btn btn-primary' id ='adTotalPays' href='/Lvscore_Advertiser_Maven/advertiserWeb/views/adTotalPay/adTotalPays.html?selectedNav=3&navPos=0&endTime="+data.endTime+"&startTime="+data.startTime+"'>查看</a></td>" +
			"</tr>";
	
				$('#index').append(body)
			}else{
				var body = "<tr>" +
				"<td>"+1+"</td>" +
				"<td>"+data.startTime+'至'+data.endTime+"</td>" +
				"<td class='avg'>"+(beans[0].averagePirce*1).toFixed(2)+"</td>" +
				"<td class='clickNums'>"+beans[0].clickNum+"</td>" +
				"<td class='dayPays'>"+(beans[0].adPay*1).toFixed(2)+"</td>" +
				"<td class='balances'>"+advertiser.actualBalance+"</td>" +
				"<td><a class='btn btn-primary' id ='adTotalPays' href='/Lvscore_Advertiser_Maven/advertiserWeb/views/adTotalPay/adTotalPays.html?selectedNav=3&navPos=0&endTime="+data.endTime+"&startTime="+data.startTime+"'>查看</a></td>" +
			"</tr>";
	
		$('#index').append(body)
			}
			
		},
        error: function(data){
        	//alert(data);
        }        
	});
 }

function byIndex(startTime,endTime){
		    	$.ajax({
					url : '/Lvscore_Advertiser_Maven/byTotalDays',
			        data:{"startTime":startTime,"endTime":endTime},
					type : 'post',
					dataType:'json',
					success : function(data) {
						$('#index tr').each(function(k){
							if(k>0){
								$('#index tr').eq(k).remove();
							}					
						})				
						$("#endTime").val(data.endTime);
						$("#startTime").val(data.startTime);
			var beans = data.beans;
			var advertiser = data.advertiser;
			if(beans[0] ==null){
				var body = "<tr>" +
				"<td>"+1+"</td>" +
				"<td>"+data.startTime+'至'+data.endTime+"</td>" +
				"<td class='avg'>"+'0'+"</td>" +
				"<td class='clickNums'>"+'0'+"</td>" +
				"<td class='dayPays'>"+'0'+"</td>" +
				"<td class='balances'>"+advertiser.actualBalance+"</td>" +
				"<td><a class='btn btn-primary' id ='adTotalPays' href='/Lvscore_Advertiser_Maven/advertiserWeb/views/adTotalPay/adTotalPays.html?selectedNav=3&navPos=0&endTime="+data.endTime+"&startTime="+data.startTime+"'>查看</a></td>" +
			"</tr>";
	
				$('#index').append(body)
			}else{
				var body = "<tr>" +
				"<td>"+1+"</td>" +
				"<td>"+data.startTime+'至'+data.endTime+"</td>" +
				"<td class='avg'>"+(beans[0].averagePirce*1).toFixed(2)+"</td>" +
				"<td class='clickNums'>"+beans[0].clickNum+"</td>" +
				"<td class='dayPays'>"+(beans[0].adPay*1).toFixed(2)+"</td>" +
				"<td class='balances'>"+advertiser.actualBalance+"</td>" +
				"<td><a class='btn btn-primary' id ='adTotalPays' href='/Lvscore_Advertiser_Maven/advertiserWeb/views/adTotalPay/adTotalPays.html?selectedNav=3&navPos=0&endTime="+data.endTime+"&startTime="+data.startTime+"'>查看</a></td>" +
			"</tr>"
				$('#index').append(body)
					}
				  },  
				});
	  }



